package com.easy.frame.base.basic.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * 系统异常日志表
 *
 * @author zzf
 * @since 2021-01-06
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@TableName("sys_exception_log")
@ApiModel("系统异常日志表")
public class SysExceptionLog implements Serializable {

    @ApiModelProperty("编号")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("链路追踪编号(以后引入链路追踪使用)")
    private String traceId;

    @ApiModelProperty("用户id")
    private Long userId;

    @ApiModelProperty("访问地址")
    private String uri;

    @ApiModelProperty("参数")
    private String queryString;

    @ApiModelProperty("http方法")
    private String method;

    @ApiModelProperty("userAgent")
    private String userAgent;

    @ApiModelProperty("ip")
    private String ip;

    @ApiModelProperty("异常名")
    private String exceptionName;

    @ApiModelProperty("异常导致的消息")
    private String exceptionMessage;

    @ApiModelProperty("异常导致的根消息")
    private String exceptionRootCauseMessage;

    @ApiModelProperty("异常的栈轨迹")
    private String exceptionStackTrace;

    @ApiModelProperty("异常发生的类全名")
    private String exceptionClassName;

    @ApiModelProperty("异常发生的类文件")
    private String exceptionFileName;

    @ApiModelProperty("异常发生的方法名")
    private String exceptionMethodName;

    @ApiModelProperty("异常发生的方法所在行")
    private Integer exceptionLineNumber;

    @ApiModelProperty("异常发生时间")
    private Date createTime;

    @ApiModelProperty("处理人")
    private Integer dealer;

    @ApiModelProperty("处理状态[0-未处理 1-已处理]")
    private Integer dealStatus;

    @ApiModelProperty("处理时间")
    private Date dealTime;

    @ApiModelProperty("处理备注")
    private String dealMemo;

    public String simpleInfo() {
        return exceptionName + ":" + "{" +
                "traceId: " + traceId +
                ", method: " + method +
                ", uri: " + uri +
                ", queryString: " + queryString +
                ", className: " + exceptionClassName +
                ", fileName: " + exceptionFileName +
                ", methodName: " + exceptionMethodName +
                ", lineNumber: " + exceptionLineNumber +
                "}";
    }
}
